package com.qdu.spring.blog.controller.test2;

import com.qdu.spring.blog.bean.test2.User2;
import com.qdu.spring.blog.service.test2.User2Service;
import com.qdu.spring.blog.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/test2")
public class User2Controller {
    @Autowired
    private User2Service user2Service;

    @RequestMapping("/insert")
    public AjaxResult insert(User2 user2){
        int i = 1/user2.getAge();
        if (user2Service.insertSelective(user2) ==1)
            return AjaxResult.successInstance("插入成功");
        else
            return AjaxResult.errorInstance("插入失败");
    }
    @RequestMapping("/select")
    public User2 select(Integer id){
        return user2Service.selectByPrimaryKey(id);
    }
}